<?php
namespace app\home\controller;
use think\Controller;
use think\Db;
use think\Session;
use think\request;

/**
 *
 * 支付页面
 */
class Cashlog extends Base
{

    //线上支付页面
    public function cashlog()
    {
        //资金日志表
        $cashlog=Db::name('cashlog')->where('uid='.Session::get('uid'))->order('id desc')->paginate(10);
        $page=$cashlog->render();
        //var_dump($cashlog);
        $this->assign('cashlog',$cashlog);
        $this->assign('page',$page);
        return $this->fetch('Cashlog/cashlog');
    }
    public function topup(){
        //充值表
        $topup=Db::name('user_recharge')->where('uid='.Session::get('uid'))->order('id desc')->paginate(10);

        $page = $topup->render();
        $topup=$topup->all();
        foreach($topup as $k=>$v){
            if($topup[$k]['paymentCode']!=0 and $topup[$k]['paymentCode']!=1000)
            {
                $topup[$k]['pays']=Db::name('payments')->where('id='.$v['paymentCode'])->value('payName');
            }else{
                if($topup[$k]['paymentCode']==0){
                    $topup[$k]['pays']='线下支付';
                }else{
                    $topup[$k]['pays']='后台充值';
                }
            }
        }
        //var_dump($topup);die;
        $this->assign('topup',$topup);
        $this->assign('page', $page);
        return $this->fetch('Cashlog/topup');
    }
    public function withdraw(){
        //提现表
        $withdraw=Db::name('user_withdrawcash')->alias('a')->join('user_bank b','b.id = a.bankId')
            ->where('a.uid='.Session::get('uid'))
            ->field('a.*,b.bankName,b.bankCard')
            ->paginate(10);
        $page = $withdraw->render();
        $this->assign('withdraw',$withdraw);
        $this->assign('page',$page);
        return $this->fetch('Cashlog/withdraw');
    }
    public function  come(){
        //出金日志
        $come=Db::name('user_futures')->where('uid='.Session::get('uid').' and eae=0')->order('id desc')->paginate(10);
        $page = $come->render();
        $this->assign('come',$come);
        $this->assign('page',$page);
        //var_dump($come);
        return $this->fetch('Cashlog/come');
    }
    public function enter(){
        //出金日志
        $enter=Db::name('user_futures')->where('uid='.Session::get('uid').' and eae=1')->order('id desc')->paginate(10);
        $page = $enter->render();
        $this->assign('enter',$enter);
        $this->assign('page',$page);
        //var_dump($come);
        return $this->fetch('Cashlog/enter');
    }
}